package abel.wlmr.model.type;

import java.util.HashMap;
import java.util.Map;

public enum BaudType {
    Baud600(1),
    Baud1200(2),
    Baud2400(3),
    Baud4800(4),
    Baud7200(5),
    Baud9600(6),
    Baud19200(7),
    BaudDefault(0);

    private byte value;

    private static Map<Byte, BaudType> baudList = new HashMap<>();
    static {
        for (BaudType b : BaudType.values()) {
            baudList.put(b.value, b);
        }
    }

    private BaudType(int v) {
        this.value = (byte) v;
    }

    public static BaudType findBaudByValue(byte v) {
        if (v < 0 || v > 7)
            return null;
        return baudList.get(v);
    }

    /**
     * @return the value
     */
    public byte getValue() {
        return value;
    }
}
